<template>
    <div class="my container">
        <header> 
            <div class="user-info" v-if="loginStatus">
                <img :src="userInfo.imgUrl" alt="">
                <span>{{userInfo.nickName}}</span>
            </div>
            <div v-else class="login" @click="goLogin">登录/注册</div>
        </header>
        <section>
            <ul>
                <li @click="goPath">地址管理</li>
                <li v-if="loginStatus" @click="loginOut">退出登录</li>
            </ul>
        </section>
        <tabbar></tabbar>
    </div>
</template>

<script>
import { mapMutations, mapState } from 'vuex';
import Tabbar from '@/components/common/Tabbar.vue';
    export default {
        name:"My",
        components: {
            Tabbar
        },
        computed: {
          ...mapState({
            loginStatus:state=>state.user.loginStatus,
            userInfo:state=>state.user.userInfo
          })  
        },
        methods:{
            ...mapMutations(['loginOut']),
            goLogin() {
                this.$router.replace('/login')
            },
            //进入地址管理
            goPath() {
                this.$router.push('/path')
            }
        }
    }
</script>

<style lang="scss" scoped>
.my {
    header {
        display: flex;
        justify-content: center;
        align-items: center;
        width: 100%;
        height: 4.2667rem;
        background-color: #b0352f;
        .login {
            padding: .16rem .4rem;
            font-size: .4267rem;
            color: #fff;
            background-color: rgba(255,181,0,0.8);
            border-radius: .1333rem;
        }
        .user-info{
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            img {
                width: 1.76rem;
                height: 1.76rem;
                border-radius: 50%;
            }
            span {
                padding: .2667rem 0;
                font-size: .48rem;
                color: #fff;
            }
        }
    }
    section {
        ul li {
            padding: .4rem;
            font-size: .4267rem;
        }
    }
}
</style>